package site.microkang.house.scheduler;

import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import site.microkang.house.external.publicity.GovPublicityPlatformHttpService;
import site.microkang.house.model.publicity.entity.HouseProjectPublicityEntity;
import site.microkang.house.service.publicity.HouseProjectPublicityService;

import java.util.List;

/**
 * 意向登记信息定时器
 * @author liukang
 * @date 2021/3/17 13:00
 */
@Component
public class IntentionRegistScheduler {
    @Autowired
    private GovPublicityPlatformHttpService govPublicityPlatformHttpService;
    @Autowired
    private HouseProjectPublicityService houseProjectPublicityService;

    //@Scheduled(cron = "0 0/30 * * * ?")
    public void intentionRegistListTask() {
        List<HouseProjectPublicityEntity> list = houseProjectPublicityService.getAll();
        if (list == null || list.size() == 0) {
            return;
        }
        list.forEach(v -> {
            String projectId = v.getProjectId();
            if (StrUtil.isNotBlank(projectId)) {
                try {
                    govPublicityPlatformHttpService.getIntentionRegistList(projectId);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
}
